<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css">
<script>
	// 验证密码
	function validate_pwd(){
		var e_pwd = document.myForm.newpwd;
		if ( e_pwd.value.length < 6 || e_pwd.value.length > 16  ) {
			e_pwd.style.border="red 1px solid";
			pwd_txt.innerHTML="<img src='imgs/no.png' align='absmiddle'><font color=red>对不起，密码长度过长或过短</font>"
			return false;
		} else {
			e_pwd.style.border="green 1px solid";
			pwd_txt.innerHTML="<img src='imgs/ok.gif' align='absmiddle'><font color=green>恭喜，密码可用</font>"
			return true;
		}
	}

	// 验证重复密码
	function validate_repwd(){
		var e_pwd = document.myForm.newpwd;
		var e_repwd = document.myForm.newpwd1;
		if ( e_repwd.value != e_pwd.value ) {
			e_pwd.style.border="red 1px solid";
			e_repwd.style.border="red 1px solid";
			pwd_txt.innerHTML="<img src='imgs/no.png' align='absmiddle'><font color=red>对不起，两次输入密码不一致</font>"
			re_txt.innerHTML="<img src='imgs/no.png' align='absmiddle'><font color=red>对不起，两次输入密码不一致</font>"
			return false;
		} else {
			e_pwd.style.border="green 1px solid";
			e_repwd.style.border="green 1px solid";
			re_txt.innerHTML="<img src='imgs/ok.gif' align='absmiddle'><font color=green>恭喜，两次密码相同</font>"
			pwd_txt.innerHTML="<img src='imgs/ok.gif' align='absmiddle'><font color=green>恭喜，密码可用</font>"
			return true;
		}
	}

	function validate(){
		if ( validate_pwd() && validate_repwd() ) {
			return true;
		} else {
			return false;
		}
	}
</script>
<!DOCTYPE>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>修改你的密码</title>
  </head>
  <body>
  	<br>
  	<div class="${ requestScope.error == null ? 'alert-success' : 'alert-danger'}">
  	${ requestScope.error == null ? "请输入密码" : requestScope.error }
  	</div>
  	<form action="/user/reset" method="post" name="myForm" onsubmit="return validate()">
  	<div class="form-group">
	   <label for="exampleInputEmail1">请输入原密码</label>
	    	<input type="password"  class="form-control" name="oldpwd" id="exampleInputEmail1" placeholder="请输入原密码" onkeyup="validate_name()"><span id="name_txt"></span>
	  </div>
	  <div class="form-group">
	    <label for="exampleInputPassword1">请输入新密码</label>
	    <input type="password" name="newpwd" class="form-control" id="exampleInputPassword1" name="pwd" placeholder="请输入新密码" onkeyup="validate_pwd()"><span id="pwd_txt"></span>
	  </div>
	   <div class="form-group">
	    <label for="exampleInputPassword2">请再次输入新密码</label>
	    <input type="password" name="newpwd1" class="form-control" id="exampleInputPassword2" name="pwd" placeholder="请再次输入新密码" onkeyup="validate_repwd()"><span id="re_txt"></span>
	  </div>
	  <button type="submit" style="margin-left: 80px; margin-top: 20px;" class="btn btn-default">提交</button>
	  <button type="reset" style="margin-left: 90px; margin-top: 20px;" class="btn btn-default">重置</button>
  	</form>
  </body>
</html>
